Socket
Socket
Sign inDemoInstall

postcss-safe-parser

Package Overview
Dependencies
11
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    postcss-safe-parser

Fault-tolerant CSS parser for PostCSS


Version published
Weekly downloads
4.6M
decreased by-23.66%
Maintainers
1
Install size
1.56 MB
Created
Weekly downloads
 

Package description

What is postcss-safe-parser?

The postcss-safe-parser package is a fault-tolerant CSS parser that can handle CSS with syntax errors. It is designed to be used with PostCSS, a tool for transforming CSS with JavaScript plugins. The safe parser can parse CSS files and recover from syntax errors gracefully, allowing developers to work with CSS that may not be perfectly formatted or may contain mistakes.

What are postcss-safe-parser's main functionalities?

Fault-tolerant CSS parsing

This feature allows developers to parse CSS with syntax errors without stopping the process. The provided code sample demonstrates how to use postcss-safe-parser with PostCSS to process a CSS string.

const postcss = require('postcss');
const safeParser = require('postcss-safe-parser');

postcss()
  .process('a { color: red; }', { parser: safeParser })
  .then(result => {
    console.log(result.css);
  });

Other packages similar to postcss-safe-parser

Changelog

Source

1.0.7

  • Parse new lines according W3C CSS syntax specification.

Readme

Source

PostCSS Safe Parser Build Status

A fault-tolerant CSS parser for PostCSS, which will find & fix syntax errors, capable of parsing any input. It is useful for:

  • Parse legacy code with many hacks. For example, it can parse all examples from Browserhacks.
  • Works with demo tools with live input like Autoprefixer demo.
Sponsored by Evil Martians

Usage

var safe   = require('postcss-safe-parser');
var badCss = 'a {';

postcss(plugins).process(badCss, { parser: safe }).then(function (result) {
    result.css //= 'a {}'
});

Keywords

FAQs

Last updated on 29 Feb 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc